{% extends "base.html" %}

{% block conteudo %}

<section class="main">
    {% include "venda/mensagem.html" %}
    
    <ol>
        <li><a href="../" accesskey="1">Voltar</a></li>
        <li><a href="../entrada/" accesskey="2">Entradas</a></li>
    </ol>
    
    <h3 class="tabela_titulo">Saída de valores {% if perms.venda.view_saida %}{% if all and all == 1 %}| <a href="../saida">Esconder</a>{% else %}| <a href="?all=1">Exibir tudo</a>{% endif %}{% endif %}</h3>
    
    {% if perms.venda.adicionar_saida %}
    <form action="" method="POST">
        <script>
            function obs() {
                $("#obs_link").hide("slow", function() {
                    $("#observacao").show("slow", function() {
                    	$(this).focus();
                    });
                });
            };
        </script>
        
        {% csrf_token %}
        <input type="text" name="valor" value="{{ valor|floatformat:2 }}" placeholder=" R$ 0,00" required autofocus />
        <input type="submit" value="Adicionar" />
        <input type="button" value="Cancelar" onclick="window.location='../';" />
        
        {% if observacao and observacao != '' %}
        <br /><textarea id="observacao" rows="3" cols="19" placeholder="Observação" name="observacao">{{ observacao }}</textarea><br />
        {% else %}
        <a id="obs_link" href="javascript:obs();">Observação</a><br />
        <textarea id="observacao" rows="3" cols="19" placeholder="Observação" name="observacao" style="display: none;"></textarea><br />
        {% endif %}
    </form>
    {% endif %}
    
    {% if saidas and perms.venda.view_saida %}
    <table>
        <tr>
            <th class="text_left">Data</th>
            <th class="text_right">Valor</th>
            <th class="text_left">Observação</th>
            <th class="text_right">Usuário</th>
            {% if perms.venda.esconder_saida %}
            <th class="text_right"></th>
            {% endif %}
        </tr>
        {% for saida in saidas %}
        <tr id="saida_{{ saida.id }}">
            <td class="text_left">{{ saida.data }}</td>
            <td class="text_right">R$ {{ saida.valor|floatformat:2 }}</td>
            <td class="text_left">{{ saida.observacao }}</td>
            <td class="text_right">{{ saida.usuario }}</td>
            {% if perms.venda.esconder_saida %}
            {% if saida.exibir %}
            <td class="text_right"><a href="" onclick="return esconder({{ saida.id }});"><img class="esconder" src="/static/img/icon/hide-01.png" width="20" alt="Esconder" /></a></td>
            {% else %}
            <td class="text_right"><a href="../saida/" onclick="return exibir({{ saida.id }});"><img class="exibir" src="/static/img/icon/show-01.png" width="20" alt="Exibir" /></a></td>
            {% endif %}
            {% endif %}
        </tr>
        {% endfor %}
    </table>
    {% endif %}
    
</section>
{% endblock %}

